<?php

namespace app\modules\admin\controllers;

use app\components\SadminController;
use app\components\ViewHtmlAuto;
use app\models\user\gc\Users_zhengjianshangchuan_gcModel;
use app\models\user\gc\UsersBaseGcModel;
use app\models\user\gc\UsersBaseinfoGc;
use app\models\user\gr\UsersBaseinfoGr;
use app\models\user\gs\User_basechanpin_gsModel;
use app\models\user\gs\Users_zhengjianshangchuan_gsModel;
use app\models\user\gs\UsersBaseGsModel;
use app\models\user\gs\UsersBaseinfoGs;
use app\models\user\gs\UsersHuanjingGs;
use Yii;
use app\components\admin_menu;
use app\components\Lcms;
use app\components\API;
use app\components\Html;
use yii\base\Exception;
use app\models\FormOption;

class ViewController extends SadminController
{

    public $layout = 'main';

    /**
     * 临时关闭验证
     */
    public $enableCsrfValidation = false;

    public function actionDelete_cache()
    {
        Lcms::flush();
        $this->ShowMessage('清理完成!');
    }

    public function actionDweixinkey()
    {
        \app\models\Token::deleteAll();
        $this->ShowMessage('清理完成!');
    }

    public function actionIndex()
    {


        return $this->render('index');
    }

    /**
     * 查看错误日志
     */
    public function actionErrorlog()
    {

        $this->get_menu()->set_now(admin_menu::M_home);
        $html = (new \app\modules\admin\models\ViewError)
            ->get_html();

        return $this->render('errorlog', ['html' => $html]);
    }

    /**
     * 查看后台操作日志
     */
    public function actionLog()
    {
        $this->get_menu()->set_now(admin_menu::M_home, admin_menu::M_log);
        $html = (new \app\modules\admin\models\ViewLoglist)->get_html();
        return $this->render('log', ['html' => $html]);
    }

    public function actionUserlist()
    {
        $this->get_menu()->set_now(admin_menu::M_user);
        return $this->render('userlist', ['html' =>
            (new \app\modules\admin\models\UserList)->get_html(null, ['style' => 'margin: 22px;'])
        ]);
    }

    /**
     * 清除错误日志
     */
    public function actionClert_errorlog()
    {
        \app\models\Error::deleteAll(
// 'type=:type',[':type'=>  \app\models\Error::Err_putong]
        );
        echo json_encode(['code' => 0]);
    }

    /**
     * 开始调试
     */
    public function actionBegin()
    {
        if (defined('YII_DEBUG') && YII_DEBUG) {
            $_SESSION['debug'] = 'd';
///echo 'begin debug';
            return $this->ShowMessage('开始调试');
        } else {
            return $this->ShowMessage('必须打开在index.php中打开调试代码', '', self::msg_error);
        }
    }

    /**
     * 开始调试
     */
    public function actionStop()
    {
        if (defined('YII_DEBUG') && YII_DEBUG) {
            unset($_SESSION['debug']);
///echo 'begin debug';
            $this->ShowMessage('关闭调试');
        } else {
            $this->ShowMessage('必须打开在index.php中打开调试代码', '', self::msg_error);
        }
    }

    /**
     * 退出链接
     */
    public function actionLogout()
    {
        Yii::$app->user->logout();
        $this->redirect(
            \yii\helpers\Url::to(['/'])
        );
    }
    /*
        public function actionOrder() {
            $this->get_menu()->set_now(admin_menu::M_order);
            return (new \app\modules\admin\models\ViewOrder)
                            ->get_html($this, ['style' => 'margin: 22px;']);
        }*/


    /**
     * 用户数据之公司
     */
    public function actionUserdatags()
    {
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '公司基本信息';
        //return $this->render('userdatags');
        $view = new ViewHtmlAuto();
        $view->readOnly=true;
        $view->setClass = UsersBaseinfoGs::class;
        $view->setId = 'id';
        $view->fieldList = [
            'isbase' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'base_gs?uid='],
            'iszhengjian' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'zhengjianshangchuan_gs?uid='],
            'isgongsichanpin' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'basechanpin_gs?uid='],
            'ischanpinfengge' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'basefengge_gs?uid='],

            'iszhiliangbiaozhun' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'basezhiliangbiaozhun_gs?uid='],
            'isgongsihuanjing' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'gongsihuanjing_gs?uid='],

       ];
        return $view->out($this);
    }

    /**
     * 用户数据之工厂
     */
    public function actionUserdatagc()
    {
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '工厂基本信息';
        $view = new ViewHtmlAuto();
        $view->readOnly=true;
        $view->setClass = UsersBaseinfoGc::class;
        $view->setId = 'id';
        $view->fieldList = [
            'isbase' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'base_gc?uid='],
            'iszhengjian' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'zhengjianshangchuan_gc?uid='],
            'isgongchangchanpin' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'basechanpin_gc?uid='],
            'isgongchangshebei' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'gongchangshebei_gc?uid='],
            'ischanpinchanneng' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'chanpinchanneng_gc?uid='],
            'iszhiliangyaoqiu' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'zhiliangyaoqiu_gc?uid='],
            'isgongchanghuanjing' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'gongchanghuanjing_gc?uid='],
        ];
        return $view->out($this);
    }

    /**
     * 用户数据之个人
     */
    public function actionUserdatagr()
    {
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '个人基本信息';
        $view = new ViewHtmlAuto();
        $view->readOnly=true;
        $view->setClass = UsersBaseinfoGr::class;
        $view->setId = 'id';
        $view->fieldList = [
            'isbase' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'base_gr?uid='],
            'iszhengjian' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'zhengjianshangchuan_gr?uid='],
            'isjiaoyubeijing' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'jiaoyubeijing_gr?uid='],
            'isgongzuojingli' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'gongzuojingli_gr?uid='],

            'isjiatingchengyuan' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'jiatingchengyuan_gs?uid='],
            'isqiuzhiyixiang' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'qiuzhiyixiang_gs?uid='],
            'isqiuzhiyixiang2' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'qiuzhiyixiang_gc?uid='],
            'isziwopingjia' => ['view' => ViewHtmlAuto::viewBaseLableA,'href'=>'ziwopingjia_gs?uid='],

        ];
        return $view->out($this);
       // return $this->render('userdatagr');
    }


    /**
     * 公司基本信息
     */
    public function actionBase_gs()
    {
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '个人基本信息';
        $view = new ViewHtmlAuto();
        $view->setClass = UsersBaseGsModel::class;
        $view->setId = 'uid';
        $view->fieldList = [
            'com_name' => [],
            'legal_name' => [],
            'legal_sex' => [
                'view' => ViewHtmlAuto::viewSex
            ],
            'legal_mobile' => [],
            'com_tel' => [],
            'comCity' => [],
            'com_address' => [],
            'nianxiaoshou' => [],
            'detail' => [
                'view' => ViewHtmlAuto::viewTextarea
            ],
        ];
        return $view->out($this);
    }


    /**
     * 工厂基本信息
     */
    public function actionBase_gc()
    {
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '工厂基本信息';
        $view = new ViewHtmlAuto();
        $view->setClass = UsersBaseGcModel::class;
        $view->setId = 'uid';
        $view->fieldList = [
            'com_name' => [],
            'legal_name' => [],
            'legal_sex' => [
                'view' => ViewHtmlAuto::viewSex
            ],
            'legal_mobile' => [],
            'com_tel' => [],
            'comCity' => [],
            'com_address' => [],
            'detail' => [
                'view' => ViewHtmlAuto::viewTextarea
            ],
        ];
        return $view->out($this);
    }






    /**
     * 公司的证件信息
    */
    public function actionZhengjianshangchuan_gs(){
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '公司的证件信息';
        $view = new ViewHtmlAuto();
        $view->setClass = Users_zhengjianshangchuan_gsModel::class;
        $view->setId = 'uid';

        $view->fieldList = [
            'xingxiangzhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'shenfenzhengzhengmian' => [ 'view' => ViewHtmlAuto::viewPic],
            'shenfenzhengfanmian' => [ 'view' => ViewHtmlAuto::viewPic],
            'jiangzhuang' => [ 'view' => ViewHtmlAuto::viewPic],
            'jiehunzheng' => [ 'view' => ViewHtmlAuto::viewPic],

            'jiashizheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'zuzhijiegoudaimazhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'yingyezhizhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'shuiwudengjizheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'zulinhetongzhao' => [ 'view' => ViewHtmlAuto::viewPic],

            'geleixukezheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'geleirongyu' => [ 'view' => ViewHtmlAuto::viewPic],
            'fangchanzheng' => [ 'view' => ViewHtmlAuto::viewPic],
           // 'detail' => [ 'view' => ViewHtmlAuto::viewTextarea],
        ];
        return $view->out($this);
    }




    /**
     * 公司的证件信息
     */
    public function actionZhengjianshangchuan_gc(){
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '公司的证件信息';
        $view = new ViewHtmlAuto();
        $view->setClass = Users_zhengjianshangchuan_gcModel::class;
        $view->setId = 'uid';



        $view->fieldList = [

            'fangchanzheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'geleirongyu' => [ 'view' => ViewHtmlAuto::viewPic],
            'geleixukezheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'jiangzhuang' => [ 'view' => ViewHtmlAuto::viewPic],
            'jiashizheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'jiehunzheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'shenfenzhengfanmian' => [ 'view' => ViewHtmlAuto::viewPic],
            'shenfenzhengzhengmian' => [ 'view' => ViewHtmlAuto::viewPic],
            'shuiwudengjizheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'xingxiangzhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'yingyezhizhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'zulinhetongzhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'zuzhijiegoudaimazhao' => [ 'view' => ViewHtmlAuto::viewPic],






/*
            'xingxiangzhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'shenfenzhengzhengmian' => [ 'view' => ViewHtmlAuto::viewPic],
            'shenfenzhengfanmian' => [ 'view' => ViewHtmlAuto::viewPic],
            'jiangzhuang' => [ 'view' => ViewHtmlAuto::viewPic],
            'jiehunzheng' => [ 'view' => ViewHtmlAuto::viewPic],

            'jiashizheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'zuzhijiegoudaimazhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'yingyezhizhao' => [ 'view' => ViewHtmlAuto::viewPic],
            'shuiwudengjizheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'zulinhetongzhao' => [ 'view' => ViewHtmlAuto::viewPic],

            'geleixukezheng' => [ 'view' => ViewHtmlAuto::viewPic],
            'geleirongyu' => [ 'view' => ViewHtmlAuto::viewPic],
            'fangchanzheng' => [ 'view' => ViewHtmlAuto::viewPic],*/

            // 'detail' => [ 'view' => ViewHtmlAuto::viewTextarea],
        ];
        return $view->out($this);
    }



    /**
     * 公司产品
     */
    public function actionBasechanpin_gs(){
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '公司产品';
        $view = new ViewHtmlAuto();
        $view->setClass = User_basechanpin_gsModel::class;
        $view->setId = 'uid';

        $view->fieldList = [
            'chanpin' => [ ],
            'suozhilei' => [ ],
            'zhenzhilei' => [ ],

        ];
        return $view->out($this);
    }
    /**
     * 产品风格
     */
    public function actionBasefengge_gs(){
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '产品风格';
        $view = new ViewHtmlAuto();
        $view->setClass = User_basechanpin_gsModel::class;
        $view->setId = 'uid';

        $view->fieldList = [
            'fengge' => [ ],

        ];
        return $view->out($this);
    }

    /**
     * 质量标准
     */
    public function actionBasezhiliangbiaozhun_gs(){
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '质量标准';
        $view = new ViewHtmlAuto();
        $view->setClass = User_basechanpin_gsModel::class;
        $view->setId = 'uid';

        $view->fieldList = [
            'zhiliangbiaozhun' => [ ],

        ];
        return $view->out($this);
    }


    /**
     * 公司环境
     */
    public function actionGongsihuanjing_gs(){
        $this->get_menu()->set_now(admin_menu::M_user);
        $this->pageTitle = '公司环境';
        $view = new ViewHtmlAuto();
        $view->setClass = UsersHuanjingGs::class;
        $view->setId = 'uid';

        $view->fieldList = [
            "caigoubu"=>[],
            "caiwubu"=>[],
            "cangchubu"=>[],
            'dianshangbu'=>[],
            'huiyishi'=>[],
            'jishubu'=>[],
            'pinkongbu'=>[],
            'renshibu'=>[],
            'shejibu'=>[],
            'shengchanbu'=>[],
            'waifabu'=>[],
            'wuliubu'=>[],
            'xiaoshoubu'=>[],
            'xingzhengbu'=>[],
            'zhanshiting'=>[],
            'zhaoshangbu'=>[],
            'zongjingban'=>[]
        ];
        return $view->out($this);
    }


}
